package com.bawei.composeui2207a.view

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

/**
 * 作者：赵亮
 * 时间：2024/12/11 16:48
 * 功能：消息页面
 */
@Composable
fun MessagePage() {
    LazyColumn {
        items(30) {
            var isSelect by remember {
                mutableStateOf(false)
            }

            var num by remember {
                mutableStateOf(10)
            }

            Box(
                modifier = Modifier
                    .background(
                        color = if (isSelect) Color.Red else Color.White,
                        shape = RoundedCornerShape(15.dp)
                    )

            ) {
                Text(
                    text = if (isSelect) "已关注${num + 1}" else "关注${num}",
                    modifier = Modifier
                        .border(
                            width = 1.dp,
                            color = Color.Black,
                            shape = RoundedCornerShape(15.dp)
                        )
                        .padding(horizontal = 20.dp, vertical = 5.dp)
                        .clickable {
                            isSelect = !isSelect
                        }
                )

            }

        }
    }
}

@Preview
@Composable
fun MessagePagePreview() {
    MessagePage()
}

